import React, { useState, useCallback } from "react";
import Son from "./Son";

export default function Index() {
  console.log("父组件渲染");
  const [name, setName] = useState("张三疯");
  const [age, setAge] = useState(12);

  const changeAge=()=>{
    setAge(age+1);
  }

  const changeName=()=>{
    setName("梅超风")
  }
  
  return (
    <div>
      <h1>useMemo</h1>
      <p>姓名:{name}</p>
      <input type="button" value="修改name" onClick={changeName} />
      <p>年龄:{age}</p>
      <input type="button" value="修改age" onClick={changeAge} />
      
      <Son age={age} name={name} ></Son>
    </div>
  );
}
